package com.example.commen.other

import com.example.commen.interf.ICell
import com.scwang.smart.refresh.layout.SmartRefreshLayout

fun finishRefreshOrLoadMore(
    currentPage: Int,
    maxPage: Int,
    smartRefreshLayout: SmartRefreshLayout?,
    isFirstPage: ICell<Boolean>
) {

    if (currentPage == 1) {
        isFirstPage.cell(true)
        if (smartRefreshLayout != null) {
            smartRefreshLayout.finishRefresh()
            smartRefreshLayout.finishLoadMore()
        }
    } else {
        smartRefreshLayout?.finishLoadMore()
        smartRefreshLayout?.finishRefresh()
        isFirstPage.cell(false)
    }
    if (currentPage == maxPage||maxPage==0) {
        smartRefreshLayout?.finishLoadMoreWithNoMoreData()
    }
}